<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<link rel="shortcut icon" href="../static/favicon.ico" th:href="@{favicon.ico}"/>
	<th:block th:include="include :: header('修改商品分类')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-TbCategory-edit" th:object="${category}">
		<input name="TbCategoryId" type="hidden" th:field="*{categoryId}" />
		<input id="treeId" name="parentId" type="hidden" th:field="*{parentId}" />
		<div class="form-group">
			<label class="col-sm-3 control-label is-required">分类名称：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="categoryName" th:field="*{categoryName}" id="categoryName" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">分类等级：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="level" th:field="*{level}">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">排序：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="sort" th:field="*{sort}">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">是否生效：</label>
			<div class="col-sm-8">
				<!--<input type="radio" name="status" value="1" checked="checked">有效
				<input type="radio" name="status" value="0">无效-->
				<div class="radio-box">
					<input type="radio" name="status" id="valid">
					<label>有效</label>
					<input type="radio" name="status" id="invalid">
					<label>无效</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">修改人：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="updateId" th:field="*{updateId}">
			</div>
		</div>
	</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
	var prefix = ctx + "categoryController";
	var category=[[${category}]]
	var ststus=category.status;
	if(ststus==1){
		$("#valid").attr("checked","checked");
	}else{
		$("#valid").attr("checked","checked");
	}
	$("#form-TbCategory-edit").validate({
		onkeyup: false,
		rules:{
			TbCategoryName:{
				remote: {
					url: prefix + "/checkTbCategoryNameUnique",
					type: "post",
					dataType: "json",
					data: {
						"TbCategoryId": function() {
							return $("#TbCategoryId").val();
						},
						"parentId": function() {
							return $("input[name='parentId']").val();
						},
						"TbCategoryName": function() {
							return $.common.trim($("#TbCategoryName").val());
						},
						"status": $.form.selectCheckeds("status")
					},
					dataFilter: function(data, type) {
						return $.validate.unique(data);
					}
				}
			},
			orderNum:{
				digits:true
			},
			email:{
				email:true,
			},
			phone:{
				isPhone:true,
			},
		},
		messages: {
			"TbCategoryName": {
				remote: "部门已经存在"
			}
		},
		focusCleanup: true
	});

	function submitHandler() {
		if ($.validate.form()) {
			$.operate.save(prefix + "/edit", $('#form-TbCategory-edit').serialize());
		}
	}

	function doSubmit(index, layero){
		var tree = layero.find("iframe")[0].contentWindow.$._tree;
		if ($.tree.notAllowLastLevel(tree)) {
			var body = layer.getChildFrame('body', index);
			$("#treeId").val(body.find('#treeId').val());
			$("#treeName").val(body.find('#treeName').val());
			layer.close(index);
		}
	}
</script>
</body>
</html>
